Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Claim/proof improvements #36

Draft
wants to merge 16 commits into
base: main
Choose a base branch
from
Draft

Conversation

bryanchriswhite
Copy link
Contributor

@bryanchriswhite bryanchriswhite commented Sep 28, 2023

Changes

  • Adds poktrolld query servicer proofs [servicer-address]
  • Adds Claim protobuf type, used for persistence between claim and proof message handlers
  • Claim validation updates
    • ensure random + constant (TODO: make gov param) height offset:
      • last session end height & claim commit height
  • Proof validation updates
    • ensure proof has a corresponding claim
    • ensure proof smst root hash matches claim's
    • ensure random + constant (TODO: make gov param) height offset:
      • claim commit height & proof commit height

TODO

  • Factor out claim & height offset helpers
  • Use them to implement relayer-side claim & proof delays
  • Fix type imports

@bryanchriswhite bryanchriswhite self-assigned this Sep 28, 2023
proto/poktroll/servicer/claim.proto Show resolved Hide resolved
@@ -12,6 +12,9 @@ message Session {
string session_id = 1;
uint64 session_number = 2; // The session number
uint64 session_block_start_height = 3; // The height at which the session started
// TODO_CONSIDERATION: do we really need this field? This should be a
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, we can probably remove it.

The ONLY thing I haven't thought through is how to handle changes in the number of blocks per session while a session is active.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had some thoughts about this. We could have a map of previous session numbers with their heights each time gov. changes this parameter (à la protocol upgrade).

Then if we want to check the height of a session we should calculate it using this map, eg.

[1, 10]: 20 // 2 blocks per session
[11, 15]: 40 // 11 to 15 had 4 blocks per session

If after session height 15, we have 5 blocks per session and we are at block 20 we do 40 + ((20 - 15) * 5) = 85 which is the block height for session 20. (don't mind off-by-one errors in the example if there are)

It also let us calculate the block height of any past session.

We may have a slightly more complex structure if we want different blocks_per_session per service.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's leave this for a post-alpha discussion and just assume a constant (governance-driven) parameter for now. What you're describing will work but I want to see if we can make it simpler.

@@ -12,6 +12,9 @@ message Session {
string session_id = 1;
uint64 session_number = 2; // The session number
uint64 session_block_start_height = 3; // The height at which the session started
// TODO_CONSIDERATION: do we really need this field? This should be a
// governance parameter & can't be trusted/used by the servicer
// msgServer/keeper.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// msgServer/keeper.
// msgServer/keeper. Need to think through what we want to do when
// the number of blocks per session changes during an active session.

@@ -33,8 +33,10 @@ message MsgClaim {
bytes smst_root_hash = 2;
// IMPROVE: move session_id into a new session_header field
string session_id = 3;
uint64 session_number = 4;
// TECHDEBT: expiration_height is not used right now and could be computed from on-chain data
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// TECHDEBT: expiration_height is not used right now and could be computed from on-chain data
// TECHDEBT: invalidation_height is not used right now and could be computed from on-chain data

relayer/client/txs.go Show resolved Hide resolved
x/servicer/keeper/msg_server_claim.go Outdated Show resolved Hide resolved
x/servicer/keeper/msg_server_claim.go Show resolved Hide resolved
x/servicer/keeper/msg_server_claim.go Show resolved Hide resolved
// TODO_THIS_COMMIT: factor all this out to a library pkg so that it can be
// reused in the client / relayer.
// TODO_CONSIDERATION: we can do this in terms of sessionId instead of
// lastEndedSessionStartHeight; however, it would require refactoring the
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bryanchriswhite I believe I see what you're getting at now:

- App { } # Independent
- Session { SessionHeader, Apps, Servicers }  # Depenency on AppKeeper & ServicerKeeper
- Servicer { /* business logic using Session */ }  # Dependency on SessionKeeper

A session is mean't to be a library (e.g. match watchers with sessions in the future as well), and I can see it having a dependency on Portals in the future as well. Embedding it inside the Servicer feels incorrect.

What I think we should do is keep the Session separate for now (as it is right now) and keep seeing how many hacks/inconveniences we'll go through.

cc @red-0ne

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will look into the different refactoring attempts then try to address this in a separate task

x/servicer/keeper/msg_server_proof.go Show resolved Hide resolved
@Olshansk
Copy link
Member

Olshansk commented Oct 3, 2023

@red-0ne Please re-request a review on this PR when it's ready for a second look.

@red-0ne
Copy link
Contributor

red-0ne commented Oct 5, 2023

Addressed the review comments. Will continue tightening the claim/proof flow making sure it works as intended.

Will continue form this to add mint/burn logic

@red-0ne red-0ne requested review from Olshansk and removed request for red-0ne October 5, 2023 18:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants